#include<stdio.h>
#include<stdarg.h>
#include<stdlib.h>
#define _GNU_SOURCE         /* See feature_test_macros(7) */


void printfNum(int count,...) //count表示可变参数个数
{
    va_list arg;
    va_start(arg,count);
    for(int i = 0 ; i < count ; i++ )
    {
         int curr = va_arg(arg,int);
         printf("param[%d]:%d\n",i,curr);
    } 
    va_end(arg);
}

void myprintf(const char* fmt,...)
{  
    va_list arg;
    va_start(arg,fmt);
    char* res;
    int ret = vasprintf(&res,fmt,arg);
    if(ret != -1)
    {
       printf(res);
       printf("\n");
       free(res); //记得释放！！！
    }
    va_end(arg);
} 

int main()
{
  printfNum(5,111,222,333,444,555);
  myprintf("%s:%d","数学",99);
  return 0;
}
